from tools import all_flow
from global_parameter import ip, port, username, DB_NAME

channel_3v0_scene1 = [
    "NULL, 1, 1, 1, '1', 5, '1', 2, '2023-03-23 15:31:08', NULL, '', 3, '', '1', NULL, NULL, NULL",
    "NULL, 1, 2, 2, '2', 5, '1', 2, '2023-03-23 15:31:08', NULL, '', 3, '', '1', NULL, NULL, NULL",
    "NULL, 1, 3, 3, '3', 5, '1', 2, '2023-03-23 15:31:08', NULL, '', 3, '', '1', NULL, NULL, NULL"]

no_group_3v0 = [
    "1, 1, 5, 1",
    "1, 2, 5, 1",
    "1, 3, 5, 1"]

v_arg_3v0_gao_2_bing_1_fen = [8, 0, False, False, False,
                              5, 3, False, True, False,
                              4, 0, False, False, False,
                              3, 0, False, False, False]

v_arg_3v0_gao_2_bing_1_tong = [8, 0, False, False, False,
                               5, 3, True, False, False,
                               4, 0, False, False, False,
                               3, 0, False, False, False]

v_arg_3v0_gao_3_bing = [8, 0, False, False, False,
                        5, 3, False, False, False,
                        4, 0, False, False, False,
                        3, 0, False, False, False]

algo_3v0_scene1 = [
    "4, '1', '1', '1,3', '0', '', '0', NULL, '2023-04-14 11:44:50', NULL, NULL, NULL, NULL, NULL, 7, 14, 7, 14, '0', '0', '1'"]

algo_3v0_scene2 = [
    "4, '2', '1', '1,3', '0', '', '0', NULL, '2023-04-14 11:44:50', NULL, NULL, NULL, NULL, NULL, 7, 14, 7, 14, '0', '0', '1'"]

# ILAE-1138 计算状态码_自适应算法_3V0分列1条
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_2_bing_1_fen, "ILAE-1138", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene2, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [None, None, 0.0, None, None, 0.0, None, None, 0.0], [None, None, 0.0, None, None, 0.0, None, None, 0.0],
         ['0', '0', '3'], ['正常评估', '正常评估', '线路分列运行'], time_data=[-1, 780])

# ILAE-1139 计算状态码_自适应算法_3V0全分列
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_2_bing_1_fen, "ILAE-1139", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene2, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['3', '3', '3'], ['线路分列运行', '线路分列运行', '线路分列运行'], time_data=[-1, 780],
         update_sqls=[
             'UPDATE da_voltage_data_temp SET aa_fundamental_phase=26, bb_fundamental_phase=26,cc_fundamental_phase=26 WHERE channel_num=2;'])

# ILAE-1140 计算状态码_自适应算法_3V0全同源
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_2_bing_1_tong, "ILAE-1140", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene2, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['2', '2', '2'], ['信号同源且同电压等级下无并列运行线路', '信号同源且同电压等级下无并列运行线路',
                           '信号同源且同电压等级下无并列运行线路'], time_data=[-1, 780], v_220_all_ty=True)

# ILAE-1155 计算状态码_通用算法_3V0同源01
# 实际造数据为1、3同源，2与（1、3）并列
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_2_bing_1_tong, "ILAE-1155", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene1, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['4', '4', '4'], ['线路运行模式变化', '线路运行模式变化', '线路运行模式变化'], time_data=[-1, 780])

# ILAE-1156 计算状态码_通用算法_3V0同源02
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_2_bing_1_tong, "ILAE-1156", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene1, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['2', '2', '2'], ['信号同源且同电压等级下无并列运行线路', '信号同源且同电压等级下无并列运行线路',
                           '信号同源且同电压等级下无并列运行线路'], time_data=[-1, 780], v_220_all_ty=True)

# ILAE-1157 计算状态码_通用算法_3V0分列01
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_2_bing_1_fen, "ILAE-1157", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene1, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [None, None, 0.0, None, None, 0.0, None, None, 0.0], [None, None, 0.0, None, None, 0.0, None, None, 0.0],
         ['4', '4', '4'], ['线路运行模式变化', '线路运行模式变化', '线路运行模式变化'], time_data=[-1, 780])

# ILAE-1158 计算状态码_通用算法_3V0分列02
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_2_bing_1_fen, "ILAE-1158", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene1, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['3', '3', '3'], ['线路分列运行', '线路分列运行', '线路分列运行'], time_data=[-1, 780],
         update_sqls=[
             'UPDATE da_voltage_data_temp SET aa_fundamental_phase=26, bb_fundamental_phase=26,cc_fundamental_phase=26 WHERE channel_num=2;'])

# ILAE-1159 计算状态码_通用算法_3V0停电01
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_3_bing, "ILAE-1159", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene1, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['4', '4', '4'], ['线路运行模式变化', '线路运行模式变化', '线路运行模式变化'], time_data=[-1, 780],
         update_sqls=[
             'UPDATE da_voltage_data_temp SET aa_fundamental_amplitude=floor(1 + rand()*8), bb_fundamental_amplitude=floor(1 + rand()*8), cc_fundamental_amplitude=floor(1 + rand()*8) WHERE channel_num=1;'])

# ILAE-1160 计算状态码_通用算法_3V0停电02
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_3_bing, "ILAE-1160", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene1, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['1', '1', '3'], ['线路停电', '线路停电', '线路分列运行'], time_data=[-1, 780],
         update_sqls=[
             'UPDATE da_voltage_data_temp SET aa_fundamental_amplitude=floor(1 + rand()*8), bb_fundamental_amplitude=floor(1 + rand()*8), cc_fundamental_amplitude=floor(1 + rand()*8) WHERE channel_num=1 or channel_num=2;'])

# ILAE-1161 计算状态码_通用算法_3V0停电03
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_3_bing, "ILAE-1161", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene1, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['1', '1', '1'], ['线路停电', '线路停电', '线路停电'], time_data=[-1, 780],
         update_sqls=[
             'UPDATE da_voltage_data_temp SET aa_fundamental_amplitude=floor(1 + rand()*8), bb_fundamental_amplitude=floor(1 + rand()*8), cc_fundamental_amplitude=floor(1 + rand()*8) WHERE channel_num=1 or channel_num=2 or channel_num=3;'])

# ILAE-1162 计算状态码_自适应算法_3V0停电01
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_3_bing, "ILAE-1162", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene2, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, None, None, 0.0, None, None, 0.0, None, None], [0.0, None, None, 0.0, None, None, 0.0, None, None],
         ['1', '0', '0'], ['线路停电', '正常评估', '正常评估'], time_data=[-1, 780],
         update_sqls=[
             'UPDATE da_voltage_data_temp SET aa_fundamental_amplitude=floor(1 + rand()*8), bb_fundamental_amplitude=floor(1 + rand()*8), cc_fundamental_amplitude=floor(1 + rand()*8) WHERE channel_num=1;'])

# ILAE-1163 计算状态码_自适应算法_3V0停电02
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_3_bing, "ILAE-1163", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene2, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['1', '1', '3'], ['线路停电', '线路停电', '线路分列运行'], time_data=[-1, 780],
         update_sqls=[
             'UPDATE da_voltage_data_temp SET aa_fundamental_amplitude=floor(1 + rand()*8), bb_fundamental_amplitude=floor(1 + rand()*8), cc_fundamental_amplitude=floor(1 + rand()*8) WHERE channel_num=1 or channel_num=2;'])

# ILAE-1164 计算状态码_自适应算法_3V0停电03
all_flow(ip, port, username, DB_NAME, v_arg_3v0_gao_3_bing, "ILAE-1164", channel_3v0_scene1, no_group_3v0,
         algo_3v0_scene2, [150, 150, 150, 150, 150, 150, 150, 150, 150],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         ['1', '1', '1'], ['线路停电', '线路停电', '线路停电'], time_data=[-1, 780],
         update_sqls=[
             'UPDATE da_voltage_data_temp SET aa_fundamental_amplitude=floor(1 + rand()*8), bb_fundamental_amplitude=floor(1 + rand()*8), cc_fundamental_amplitude=floor(1 + rand()*8) WHERE channel_num=1 or channel_num=2 or channel_num=3;'])
